package com.wwinsoft.oa.service.aftersales;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wwinsoft.modules.orm.Page;
import com.wwinsoft.modules.utils.PropertiesUtils;
import com.wwinsoft.oa.dao.aftersales.AftersalesMaintainDao;
import com.wwinsoft.oa.dao.aftersales.AftersalesMaintainQueryDao;
import com.wwinsoft.oa.entity.aftersales.AftersalesMaintain;
import com.wwinsoft.oa.pojo.aftersales.AftersalesMaintainBean;
/**
 * @author: Tim Chen
 * @since 1.0
 */
@Service
@Transactional
public class AftersalesService {

    @Autowired
    private AftersalesMaintainDao aftersalesMaintainDao ;

 // add by sevenSpend 2011/12/10 start -->
    @Autowired
    private AftersalesMaintainQueryDao aftersalesMaintainQueryDao;
 // <-- add by sevenSpend 2011/12/10 end 
    public void saveAftersalesMaintain(AftersalesMaintain aftersalesMaintain){
          aftersalesMaintainDao.save(aftersalesMaintain);
    }

    @Transactional(readOnly = true)
    public AftersalesMaintain getAftersalesMaintain(Long id){
          return  aftersalesMaintainDao.get(id);
    }

    @Transactional(readOnly = true)
    public Page<AftersalesMaintainBean> searchAftersalesMaintain(Page<AftersalesMaintainBean> page , Object filter) {
        Map paraMap = PropertiesUtils.toParameterMap(filter);
        return aftersalesMaintainQueryDao.searchAftersalesMaintainPage(page, paraMap);
    }
// add by sevenSpend 2011/12/10 start -->
    @Transactional(readOnly = true)
    public List<AftersalesMaintainBean> searchAftersalesMaintain(Object filter) {
        Map paraMap = PropertiesUtils.toParameterMap(filter);
        return aftersalesMaintainQueryDao.searchAftersalesMaintain(paraMap);
    }
// <-- add by sevenSpend 2011/12/10 end 
    public void archiveAftersalesMaintain(Long id){
        AftersalesMaintain aftersalesMaintain = aftersalesMaintainDao.get(id);
        aftersalesMaintain.setProcessEndTime(new Date());
        aftersalesMaintain.setStatus(aftersalesMaintain.STATUS_COMPLETE);
        aftersalesMaintainDao.save(aftersalesMaintain);
    }
}
